$(function(){
	
	$.ajax({
		type:"post",
		url: "/Home/index/user",
		success:function(data){
			dataList(data.data)
		}
	});
	function dataList(data){
		show(data,0);
	//人物列表
		var figureListHtml = '';
		for(var i=0;i<data.length;i++){
		figureListHtml+=`<li index="${i}">
							<img src="${data[i].user_img}" alt="" />
							<div class="mask" style="display:none">
								<span class="xiangshang"></span>
								<p class="maskText">
									<strong>${data[i].title}</strong>
									<strong>${data[i].username}</strong>
								</p>
							</div>
						</li>`
	}
	$('.figureList').css("width",data.length*370+"px")
	$('.figureList').html(figureListHtml);
	//移入让遮罩显示
	$('.figureList li').mouseover(function(){
		$(this).find(".mask").css("display","block");
	});
	//移出让遮罩隐藏
	$('.figureList li').mouseout(function(){
		$(this).find(".mask").css("display","none");
	});
	//点击切换显示内容
	$('.figureList li').click(function(){
		show(data,$(this).attr("index"))
	})
	//左右切换
	 $('.rightJ').click(function () {  
        $(".figureList").animate({marginLeft:"-800px"},100, function () {  
            $(".figureList >li").eq(0).appendTo($(".figureList"));  
            $(".figureList").css('marginLeft','0px');  
        });  
   });  
	$('.leftJ').click(function () {  
	        $(".figureList").animate({marginLeft:"800px"},100, function () {  
            $(".figureList >li").eq($(".figureList li").length-1).prependTo($(".figureList"));  
            $(".figureList").css('marginLeft','0px');  
        });
	   })
	}
	
	  
})
function show(data,num){
	var title = data[num].discrip.split(",");
		var titleName = '';//头衔
		for(var i=0;i<title.length;i++){
			titleName+=`<h4 class="title1">${title[i]}</h4>`
		}
		$(".titles").html(titleName)
		//详细信息
		$(".info").html(data[num].content);
		//名字
		$(".name").html(data[num].username);
		//照片
		$(".bigImg").attr("src",data[num].user_img)
		
}
